package ru.cod.rs.object;

import ru.cod.rs.object.actions.AbstractActions;
import ru.cod.rs.types.Coords;
import android.graphics.Bitmap;
import android.graphics.Canvas;

/**
 * ����������� ������ - ����������� ���� �������� ������� ���������� �
 * ����������� �� �����
 * 
 * @author Admin
 * 
 */
public class StateObject implements AbstractActions {

	protected final String TAG = this.getClass().getSimpleName();

	protected Bitmap image;
	protected int x, y;

	protected int width, height;

	// //////////////////////

	public StateObject(Bitmap b) {
		this(b, 0, 0);
	}

	public StateObject(Bitmap b, int abc, int ord) {
		image = b;

		setCoords(abc, ord);
		setSize();
	}

	// ////////////////////

	public void draw(Canvas c) {
		c.drawBitmap(image, x, y, null);
	}

	// ////////////////////
	protected void setSize() {
		if (image != null) {
			width = image.getWidth();
			height = image.getHeight();
		} else {
			width = height = 0;
		}
	}

	public void setImage(Bitmap b) {
		image = b;
		setSize();
	}

	public void setX(int abc) {
		x = abc;
	}

	public void setY(int ord) {
		y = ord;
	}

	public void setCoords(int abc, int ord) {
		x = abc;
		y = ord;
	}
	
	public void setCoords(Coords c) {
		x=c.getX();
		y=c.getY();
	}

	public void setSize(int w, int h) {
		width = w;
		height = h;
	}

	// ////////////////////////////
	public Bitmap getImage() {
		return image;
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public int getWidth() {
		int result = 0;
		if (width == 0) {
			width = image.getWidth();
		}
		if (width > 0) {
			result = width;
		}
		return result;
	}

	public int getHeight() {
		int result = 0;
		if (height == 0) {
			height = image.getHeight();
		}
		if (height > 0) {
			result = height;
		}
		return result;
	}
}
